<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript">
    $(function () {
        $('.land-table').dataTable({
            aaSorting: [],
            "sPaginationType": "full_numbers",
            "bDestroy": true,
            "oLanguage": {
                "sZeroRecords": $('#no-record').val(),
                "sLengthMenu": $('#display').val() + " _MENU_ " + $('#records').val(),
                "sSearch": $('#search').val(),
                "sInfo": $('#showing').val() + " _START_ " + $('#to').val() + " _END_ " + $('#of').val() + " _TOTAL_ " + $('#entries').val(),
                "sInfoEmpty": $('#no-record').val(),
                "oPaginate": {
                    "sFirst": $('#first').val(),
                    "sLast": $('#last').val(),
                    "sNext": $('#next').val(),
                    "sPrevious": $('#previous').val()
                }
            },
            "fnDrawCallback": function () {
                if ($('.dataTables_paginate span span.paginate_button').size()) {
                    $('.dataTables_paginate')[0].style.display = "block";
                } else {
                    $('.dataTables_paginate')[0].style.display = "none";
                }
            }
        });
    });
</script>

<div id="land-registration-module-home-title" class="module-home-title">
    <s:a href="landAlienationModuleHome.do"><img src="${pageContext.request.contextPath}/images/land-reg.png"
                                                 alt="Land Alienation"><span><s:label
            value="%{getText('land_alienation.label')}"/></span></s:a>

    <div id="back-button" align="right">
            <s:form><s:submit value="%{getText('back_btn.label')}" action="landAlienationModuleHome"/></s:form>
        </div>
</div>

<h2><s:label value="%{getText('detailed_alienation_applications.label')}"/></h2>
<h3><s:property value="workflowTask"/></h3>

<table class="width-100 margin-10-auto table land-table">
    <thead>
    <tr class="center-align table-header">
        <th><s:label value="%{getText('ds_division.label')}"/></th>
        <th><s:label value="%{getText('applied_date.label')}"/></th>
        <th><s:label value="%{getText('applicant_name.label')}"/></th>
        <th><s:label value="%{getText('status.label')}"/></th>
        <th><s:label value="%{getText('action.label')}"/></th>
    </tr>
    </thead>
    <tbody>
    <s:iterator status="status" value="landApplicationList">
        <tr class="<s:if test="#status.odd == true">table-row-odd</s:if><s:else>table-row-even</s:else>">
        <s:if test=" language=='en' ">
                 <td class="center-align"><s:property value="dsDivision.enDivisionName"/></td>
        </s:if>
        <s:elseif test=" language=='si' ">
            <td class="center-align"><s:property value="dsDivision.siDivisionName"/></td>
        </s:elseif>
        <s:elseif test=" language=='ta' ">
            <td class="center-align"><s:property value="dsDivision.taDivisionName"/></td>
        </s:elseif>
            <td class="center-align"><s:property value="submitDate"/></td>
            <td class="center-align"><s:property value="holder.name"/></td>
            <td class="center-align"><s:property value="workflowItem.workflowTask.action"/></td>
            <td class="center-align">

                <s:if test="#session.userGroup =='ma'">

                    <s:if test="workflowItem.id == @lk.icta.common.AppConstants@PLC_APPROVED">

                        <%--<s:url id="getAgreementType" action="getAgreementType">
                            <s:param name="applicationId" value="id"/>

                        </s:url>
                        <s:a href="%{getAgreementType}" title="%{getText('view_agreement_tooltip')}">
                            <img src="<s:url value='/images/agreement.png'/>" border="none" width="25"
                                 height="25"/>
                        </s:a>--%>

                        <s:url id="addLeasePayment" action="addLeasePayment">
                            <s:param name="applicationId" value="id"/>

                        </s:url>
                        <s:a href="%{addLeasePayment}" title="Add Lease Payment Detail">
                            <img src="<s:url value='/images/lease-payment.png'/>" border="none" width="25"
                                 height="25"/>
                        </s:a>

                        <s:url id="letterToMinistry" action="letterToMinistry">
                            <s:param name="applicationId" value="id"/>

                        </s:url>
                        <s:a href="%{letterToMinistry}" title="Ministry">
                            <img src="<s:url value='/images/init-form.png'/>" border="none" width="25"
                                 height="25"/>
                        </s:a>
                    </s:if>

                    <s:if test="workflowItem.id == @lk.icta.common.AppConstants@ORLP_APPROVED">
                        <s:url id="letterToPlc" action="letterToPlc">
                            <s:param name="applicationId" value="id"/>

                        </s:url>
                        <s:a href="%{letterToPlc}" title="Plc">
                            <img src="<s:url value='/images/detailed-form.png'/>" border="none" width="25"
                                 height="25"/>
                        </s:a>
                    </s:if>
                </s:if>

                    <%--<s:url id="initDetailApplication" action="initDetailApplication">
                        <s:param name="applicationId" value="id"/>
                    </s:url>
                    <s:a href="%{initDetailApplication}" title="%{getText('approve_tooltip')}">
                        <img src="<s:url value='/images/approve.png'/>" border="none" width="25"
                             height="25"/>
                    </s:a>--%>

                <s:if test="#session.userGroup =='lo' || #session.userGroup =='ords'">
                    <s:if test="workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@ACCEPTED_AND_COMPLETED_APPLICATION_APPROVED ||
                    workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@SIGNED_PRINTED_ALIENATION_DOCUMENT ||
                    workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@UNSIGNED_PRINTED_ALIENATION_DOCUMENT ||
                    workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@ALIENATION_APPROVED_BY_LC ||
                    workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@FULLY_APPROVED">

                        <s:url id="getAgreementType" action="getAgreementType">
                            <s:param name="applicationId" value="id"/>

                        </s:url>
                        <s:a href="%{getAgreementType}" title="%{getText('view_agreement_tooltip')}">
                            <img src="<s:url value='/images/agreement.png'/>" border="none" width="25"
                                 height="25"/>
                        </s:a>

                        <s:url id="loadAttachAlienationDoc" action="loadAttachAlienationDoc">
                            <s:param name="applicationId" value="id"/>

                        </s:url>
                        <s:a href="%{loadAttachAlienationDoc}" title="%{getText('attached_alienation_doc.label')}">
                            <img src="<s:url value='/images/attachment.png'/>" border="none" width="25"
                                 height="25"/>
                        </s:a>
                    </s:if>
                    <s:elseif
                            test="workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@SIGNED_ALIENATION_DOCUMENT_APPROVED">

                        <s:url id="generateLetterOfConfirmation" action="generateLetterOfConfirmation">
                            <s:param name="applicationId" value="id"/>
                        </s:url>
                        <s:a href="%{generateLetterOfConfirmation}">
                            <img src="<s:url value='/images/register-letter.jpg'/>" border="none" width="25"
                                 height="25" title="Letter Of Confirmation"/>
                        </s:a>

                        <%-- condition satisfied --%>
                        <s:url id="viewAlienationDoc" action="viewAlienationDoc">
                            <s:param name="applicationId" value="id"/>
                            <s:param name="editMode" value="32"/>
                        </s:url>
                        <s:a href="%{viewAlienationDoc}">
                            <img src="<s:url value='/images/agreement.png'/>" border="none" width="25"
                                 height="25" title="View Alienation Doc"/>
                        </s:a>

                        <%-- <s:url id="setUpAction" action="setUpAction">
                                                    <s:param name="applicationId" value="id"/>
                                                </s:url>
                                                <s:a href="%{setUpAction}">
                                                    <img src="<s:url value='/images/icon_register.jpg'/>" border="none" width="25"
                                                         height="25" title="SetUp Action"/>
                                                </s:a>
                        --%>
                    </s:elseif>
                    <s:elseif
                            test="workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@LAND_ALLOCATION_APPROVED">

                        <s:url id="generateLetterForApplication" action="generateLetterForApplication">
                            <s:param name="applicationId" value="id"/>
                        </s:url>
                        <s:a href="%{generateLetterForApplication}">
                            <img src="<s:url value='/images/register-letter.jpg'/>" border="none" width="25"
                                 height="25" title="Application Letter"/>
                        </s:a>
                    </s:elseif>
                    <%--


                    <%-- <s:url id="getAgreementType" action="getAgreementType">
                        <s:param name="applicationId" value="id"/>

                    </s:url>
                    <s:a href="%{getAgreementType}" title="%{getText('view_agreement_tooltip')}">
                        <img src="<s:url value='/images/agreement.png'/>" border="none" width="25"
                             height="25"/>
                    </s:a>--%>

                </s:if>

                <s:elseif test="#session.userGroup =='orip'">
                                    <s:if test="
                                    workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@SIGNED_PRINTED_ALIENATION_DOCUMENT ||
                                    workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@UNSIGNED_PRINTED_ALIENATION_DOCUMENT ||
                                    workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@ALIENATION_APPROVED_BY_LC ||
                                    workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@FULLY_APPROVED">

                                        <s:url id="getAgreementType" action="getAgreementType">
                                            <s:param name="applicationId" value="id"/>

                                        </s:url>
                                        <s:a href="%{getAgreementType}" title="%{getText('view_agreement_tooltip')}">
                                            <img src="<s:url value='/images/agreement.png'/>" border="none" width="25"
                                                 height="25"/>
                                        </s:a>

                                        <s:url id="loadAttachAlienationDoc" action="loadAttachAlienationDoc">
                                            <s:param name="applicationId" value="id"/>

                                        </s:url>
                                        <s:a href="%{loadAttachAlienationDoc}" title="%{getText('attached_alienation_doc.label')}">
                                            <img src="<s:url value='/images/attachment.png'/>" border="none" width="25"
                                                 height="25"/>
                                        </s:a>
                                    </s:if>
                                    <s:elseif
                                            test="workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@SIGNED_ALIENATION_DOCUMENT_APPROVED">

                                        <s:url id="generateLetterOfConfirmation" action="generateLetterOfConfirmation">
                                            <s:param name="applicationId" value="id"/>
                                        </s:url>
                                        <s:a href="%{generateLetterOfConfirmation}">
                                            <img src="<s:url value='/images/register-letter.jpg'/>" border="none" width="25"
                                                 height="25" title="Letter Of Confirmation"/>
                                        </s:a>

                                        <%-- condition satisfied --%>
                                        <s:url id="viewAlienationDoc" action="viewAlienationDoc">
                                            <s:param name="applicationId" value="id"/>
                                            <s:param name="editMode" value="32"/>
                                        </s:url>
                                        <s:a href="%{viewAlienationDoc}">
                                            <img src="<s:url value='/images/agreement.png'/>" border="none" width="25"
                                                 height="25" title="View Alienation Doc"/>
                                        </s:a>


                                    </s:elseif>
                                    <s:elseif
                                            test="workflowItem.workflowTask == @lk.icta.core.entity.WorkflowTask@LAND_ALLOCATION_APPROVED">

                                        <s:url id="generateLetterForApplication" action="generateLetterForApplication">
                                            <s:param name="applicationId" value="id"/>
                                        </s:url>
                                        <s:a href="%{generateLetterForApplication}">
                                            <img src="<s:url value='/images/register-letter.jpg'/>" border="none" width="25"
                                                 height="25" title="Application Letter"/>
                                        </s:a>
                                    </s:elseif>


                                </s:elseif>


                <s:url id="initDetailApplication" action="initDetailApplication">
                    <s:param name="applicationId" value="id"/>
                </s:url>
                <s:a href="%{initDetailApplication}" title="%{getText('approve_tooltip')}">
                    <img src="<s:url value='/images/approve.png'/>" border="none" width="25"
                         height="25"/>
                </s:a>

            </td>
        </tr>
    </s:iterator>
    </tbody>
</table>
<%-- Localization text for data tables --%>
<s:hidden id="display" value="%{getText('display.label')}"/>
<s:hidden id="records" value="%{getText('records.label')}"/>
<s:hidden id="search" value="%{getText('search.label')}"/>
<s:hidden id="no-record" value="%{getText('no_record.label')}"/>
<s:hidden id="showing" value="%{getText('showing.label')}"/>
<s:hidden id="to" value="%{getText('to.label')}"/>
<s:hidden id="of" value="%{getText('of.label')}"/>
<s:hidden id="entries" value="%{getText('entries.label')}"/>
<s:hidden id="first" value="%{getText('first.label')}"/>
<s:hidden id="last" value="%{getText('last.label')}"/>
<s:hidden id="next" value="%{getText('next.label')}"/>
<s:hidden id="previous" value="%{getText('previous.label')}"/>